package com.yanyu.space.common.log.handler;

/**
 * @author yanyu
 */
public class LogWorkerContextHolder {

    private static final InheritableThreadLocal<LogWorkerContext> traceContextLogWorkerThreadLocal = new InheritableThreadLocal<LogWorkerContext>() {
        @Override
        protected LogWorkerContext childValue(LogWorkerContext parentValue) {
            if (parentValue == null) {
                return null;
            }
            return parentValue;
        }
    };

    public static LogWorkerContext get() {
        return traceContextLogWorkerThreadLocal.get();
    }

    public static void set(LogWorkerContext logWorkerContext) {
        traceContextLogWorkerThreadLocal.set(logWorkerContext);
    }

    public static void remove() {
        traceContextLogWorkerThreadLocal.remove();
    }
}
